<?php

function webcolor_blend($color, $background, $fact = 0.5) {
    sscanf($color, "#%02x%02x%02x", $R1, $G1, $B1);
    sscanf($background, "#%02x%02x%02x", $R2, $G2, $B2);
    return sprintf("#%02x%02x%02x",
        (int)($R1 + (($R2-$R1)*$fact)),
        (int)($G1 + (($G2-$G1)*$fact)),
        (int)($B1 + (($B2-$B1)*$fact))
    );
}
